package com.css.fxfzxczh.modules.disasterDamageInfo.repository.impl;

import com.css.fxfzxczh.modules.disasterDamageInfo.entity.DisasterAssess;
import com.css.fxfzxczh.modules.disasterDamageInfo.entity.DisasterDamage;
import com.css.fxfzxczh.modules.disasterDamageInfo.repository.DisasterAssessRepository;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author:
 * @CreateTime: 2024/4/28 10:22
 * @Description:
 */
@Repository
public class DisasterAssessRepositoryImpl implements DisasterAssessRepository {
    @Resource
    private JdbcTemplate jdbcTemplate;

    @Resource
    NamedParameterJdbcTemplate namedParameterJdbcTemplate;
    @Override
    public void batchSave(List<DisasterAssess> list) {
        SqlParameterSource[] beanSources = SqlParameterSourceUtils.createBatch(list.toArray());

        String sql = "insert into xczh_disaster_Assess_data (id,assess_unit,assess_number,create_user,create_time) " +
                "values (:id,:assessUnit,:assessNumber,:createUser,:createTime)";
        namedParameterJdbcTemplate.batchUpdate(sql, beanSources);
    }
}
